package oop.ex4.crosswords;

/**
 * A simple implementation of the CrosswordPosition interface.
 * @author yomach
 * @author mbattat
 */
public class MyCrosswordPosition implements CrosswordPosition {

	///////////////////////////////////////////////////////
	//////////////////////Data Members/////////////////////
	///////////////////////////////////////////////////////
	
	/**
	 * The x coordinate.
	 */
	protected int _x;
	
	/**
	 * The y coordinate.
	 */
	protected int _y;
	
	/**
	 * A boolean variable stating if the position is vertical or horizontal.
	 */
	protected boolean _vertical;
	
	///////////////////////////////////////////////////////
	//////////////////////Constructors/////////////////////
	///////////////////////////////////////////////////////
	
	/**
	 * A constructor that creates a new Crossword position with the given parameters.
	 * @param x The x coordinate.
	 * @param y The y coordinate.
	 * @param vertical Is the position vertical or not.
	 */
	public MyCrosswordPosition(int x, int y, boolean vertical) {
		_x = x;
		_y = y;
		_vertical = vertical;
	}
	
	///////////////////////////////////////////////////////
	/////////////////////Public Methods////////////////////
	///////////////////////////////////////////////////////
	
	@Override
	public int getX() {
		return _x;
	}

	@Override
	public int getY() {
		return _y;
	}

	@Override
	public boolean isVertical() {
		return _vertical;
	}
	
	@Override
	public String toString() {
		return "(" + _x + "," + _y + ") " + (_vertical ? "Vertical" : "Horizontal"); 
	}
	
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof CrosswordPosition)) { return false; }
		CrosswordPosition pos = (CrosswordPosition) obj;
		return (_x == pos.getX() && _y == pos.getY() && _vertical == pos.isVertical());
	}
}
